function [ isin ] = Isincylinder( cylinder_start, cylinder_end, cylinder_rad, refpoint )
%ISINCYLINDER Summary of this function goes here
%   Detailed explanation goes here
    isin=0;
    [nearestpoint distance]=distance2curve([cylinder_start;cylinder_end],refpoint,'linear');
    if isequal(nearestpoint,cylinder_start)
        if dot((refpoint-cylinder_start),(cylinder_end-cylinder_start))==0
            if distance<=cylinder_rad
                isin=1;
            end
        end           
    else if isequal(nearestpoint,cylinder_end)
           if dot((refpoint-cylinder_end),(cylinder_end-cylinder_start))==0
               if distance<=cylinder_rad
                   isin=1;
               end
           end
        else
            if distance<=cylinder_rad
                isin=1;
            end
        end        
    end
end

